home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
v cisle
/
acehtml
/
acehtmlfreeware.exe
/
scriptdef
/
Mortgage Calculator.sd
< prev
next >
Wrap
INI File
|
2004-06-28
|
5KB
|
159 lines
[SUBJECT]
Description=Calculate mortgages
ImageIndex=-1
Folder=Mathematics
[HEAD_TEXT]
;<!-- Cut-N-Paste JavaScript from ISN Toolbox
; Copyright 1996, Infohiway, Inc. Restricted use is hereby
; granted (commercial and personal OK) so long as this code
; is not *directly* sold and the copyright notice is buried
; somewhere deep in your HTML document. A link to our site
; http://www.infohiway.com is always appreciated of course,
; but is absolutely and positively not necessary. ;-) -->
;<script language="JavaScript">
;<!--Hide JavaScript from Java-Impaired Browsers
;var irate, mi, cmi, years, tprinc, princ, paym, cpaym, osp,v,downp,downr,comp;
;function calcPaym(cdn){
; tprinc = round2d(parseFloat(document.smpc.tprinc.value));
; downp = .01*parseFloat(document.smpc.downp.value);
; downr = ceil2d(downp*tprinc);
; princ = tprinc-downr;
;
; document.smpc.princ.value = fmt2d(princ,0);
; document.smpc.downr.value = fmt2d(downr,0);
;
; if(cdn)comp="Canadian"; else comp="U.S";
; document.smpc.comp.value = comp;
;
; irate = .01*parseFloat(document.smpc.percent.value);
; years=parseFloat(document.smpc.years.value);
; term = parseFloat(document.smpc.term.value);
; if(term > years)term=years;
;
; if (term==0 || years==0||irate<.0001||princ<1)
; {alert("values must be numeric");}
; else
; {
; if(cdn)mi = Math.pow(1+ irate/2,1/6);
; else mi = 1+(irate/12);
; v = 1/mi;
; paym = ceil2d(princ*(mi-1)/(1-Math.pow(mi,-(years*12))));
; osp = (princ-(v*paym*(1-Math.pow(v,12*term)))/(1-v))/Math.pow(v,12*term);
; if(osp<0)osp = 0;
;
; document.smpc.paym.value=fmt2d(paym,0);
; document.smpc.owed.value = fmt2d(osp,0);
; }
;}
;function round2d(n){return(.01* Math.round(100*n));}
;function floor2d(n){return(.01* Math.floor(100*n));}
;function ceil2d(n){return(.01* Math.ceil(100*n));}
;// format number n as string width w with 2 decimal places
;function fmt2d(n,w)
;{
; var work,dp,sl,dl;
;
; work = ""+floor2d(n); // force only 2 decimals
; sl=work.length;
;
; if(-1 == (dp = work.indexOf(".")))work=work+".00";
; else if(3 > sl-dp)work = work+".00"+substring(sl-dp,3);
; sl = work.length;
; if(0 != w && w !=sl)
; if(w<sl){work = "*";for(sl=1;sl<w;sl++)work=work+"*";}
; else for(;sl<w;sl++)work=" "+work;
; return work;
;}
;//-->
;</SCRIPT>
;
[BODY_TAG]
;bgcolor="#ffffff" text="#000000" onload="calcPaym(1)" link="#ff0000" vlink="#0000ff" alink="#000000"
[BODY_TEXT]
; <h1>`Caption`</h1>
;
; <form name="smpc">
; <div align="center">
;
; <p align="left"><b>This calculator calculates U.S. and Canadian monthly
; mortgage payments based on principal, interest and term. U.S. mortgages
; are compounded monthly while Canadian mortgages are compounded
; semi-annually.</B></P>
; <table border="0" cellpadding="5" summary="">
; <tr>
; <td align="right">
;
; <p>Amortization(Years) = </p></td>
; <td><input type="text" name="years" value="25" size="3"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p>Term (Years) = </p></td>
; <td><input type="text" name="term" value="5" size="3"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p>Yearly Interest Rate (%) = </p></td>
; <td><input type="text" name="percent" value="7" size="6"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p> Principal Amount ($) = </p></td>
; <td><input type="text" value="100000" name="tprinc" size="10"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p> Downpayment (%) = </p></td>
; <td><input type="text" value="25" name="downp" size="10"></td>
; </tr>
; <tr>
; <td align="right"><input type="button" value="calculate payment (canadian)"
;onclick="calcPaym(1)"></td>
; <td><input type="button" value="Calculate Payment (U.S)"
;onclick="calcPaym(0)"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p> Downpayment Required ($) =</p></td>
; <td><input type="text" name="downr" size="10"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p> Mortgage Principal ($) =</p></td>
; <td><input type="text" name="princ" size="10"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p>Monthly Payment ($) =</p></td>
; <td><input type="text" name="paym" size="10"><input type="text" name="comp"
;value="Canadian" size="10"></td>
; </tr>
; <tr>
; <td align="right">
;
; <p>Still Owing at End of Term ($) =</p></td>
; <td><input type="text" name="owed" size="10"></td>
; </tr>
; </table></div></form>
[`Caption`]
Kind=S
Value=Mortgage Calculator using either the Canadian or U.S. Formula